import Vue from 'vue';
import VueRouter from 'vue-router';

Vue.use(VueRouter);

const routes = [
  {
    path: '/register',
    name: 'register',
    component: () => import('@/views/register'),
    hidden: true,
    children: [
      {
        path: '',
        name: '',
        meta: { name: '注册' },
      },
    ],
  },
  {
    path: '/login',
    name: 'login',
    component: () => import('@/views/login'),
    hidden: true,
    children: [
      {
        path: '',
        name: '',
        meta: { name: '登录' },
      },
    ],
  },
  {
    path: '/',
    redirect: '/dashboard',
    component: () => import('@/layout/index.vue'),
    hidden: false,
    children: [
      {
        path: 'dashboard',
        name: 'dashboard',
        component: () => import('@/views/dashboard'),
        meta: { name: '添加电影' },
      },
    ],
  },
  {
    path: '/manage',
    component: () => import('@/layout/index.vue'),
    hidden: false,
    children: [
      {
        path: '',
        name: 'manage',
        component: () => import('@/views/manage'),
        meta: { name: '电影管理' },
      },
    ],
  },
  {
    path: '/user',
    redirect: '/user',
    component: () => import('@/layout/index.vue'),
    hidden: false,
    children: [
      {
        path: '',
        name: 'user',
        component: () => import('@/views/user'),
        meta: { name: '管理员信息' },
      },
    ],
  },
];

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes,
});

export default router;
